typedef struct {
    int *data;
    int *min;
    int top;
} MinStack;

MinStack* minStackCreate() {
    MinStack *obj = (MinStack *)malloc(sizeof(MinStack));
    obj->data = (int *)malloc(sizeof(int) * 30000);
    obj->min = (int *)malloc(sizeof(int) * 30000);
    obj->top = -1;
    return obj;
}

void minStackPush(MinStack* obj, int x) {
    obj->top++;
    obj->data[obj->top] = x;
    if (obj->top == 0) {
        obj->min[obj->top] = x;
    } else {
        obj->min[obj->top] = fmin(x, obj->min[obj->top - 1]);
    }
}

void minStackPop(MinStack* obj) {
    obj->top--;
}

int minStackTop(MinStack* obj) {
    return obj->data[obj->top];
}

int minStackGetMin(MinStack* obj) {
    return obj->min[obj->top];
}

void minStackFree(MinStack* obj) {
    free(obj->data);
    free(obj->min);
    free(obj);
}
